// pages/delivery/delivery.js
Page({

    /**
     * 页面的初始数据
     */
    data: {

        takeOrderId:"1",
        Title:[
            {
                id:0,
                name:"我的接单",
                isActive:true
            },
            {
                id:1,
                name:"我的下单",
                isActive:false
            },
    
        ],

        delivery:[

            
        ],

        task:[
        ],

        severDelivery:[

        ],

        severTask:[

        ]



    },

    navigatoDelivery:function(e){
        var that=this
        wx.showModal({
          title:"订单详情",
          content:"进入订单详情",
          success(res){
              if(res.confirm){ 
                wx.navigateTo({
                    url: '/pages/order/order?type=delivery&current= '+ JSON.stringify(e.currentTarget.id) 
                  })
              }
              else if (res.cancel)
              {
                  console.log('取消')
              }
          },
          
        })
    },

    navigatoTask:function(e){
        var that=this
        wx.showModal({ 
          title:"订单详情",
          content:"进入订单详情",
          success(res){
              if(res.confirm){ 
                wx.navigateTo({
                    url: '/pages/order/order?type=task&current= '+ JSON.stringify(e.currentTarget.id) 
                  })
              }
              else if (res.cancel)
              {
                  console.log('取消')
              }
          },
          
        })
    },

    handItemchange(e){
        const {index}=e.currentTarget.dataset;
        let {Title}=this.data;
        Title.forEach((v,i)=>i===index?v.isActive=true:v.isActive=false);
        this.setData({
            Title
        })
    },


    onLoad: function () {
        var that =this
        wx.request({
            url: 'http://119.23.252.15:10002/common/getMyConsumption',
            method:"POST",
            data:{
                token:wx.getStorageSync('token')
            },
            success(res){
                console.log(res.data)
                that.setData({
                    delivery:res.data.data.delivery,
                    task:res.data.data.task
                })
            }
          })

          wx.request({
            url: 'http://119.23.252.15:10002/common/getMyServe',
            method:"POST",
            data:{
                token:wx.getStorageSync('token') 
            },
            success(res){
                console.log(res.data)
                that.setData({
                    severDelivery:res.data.data.delivery,
                    severTask:res.data.data.task
                })
            }
          })
    },


})